﻿using Project.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Project.IService
{
    public interface IBaseService<T> where T : BaseModel, new()
    {
        Task<int> AddAsync(T obj);
        /// <summary>
        /// 将dto模型转换为实体模型后保存
        /// </summary>
        /// <typeparam name="DTO">dto类型</typeparam>
        /// <param name="dto">dto对象</param>
        /// <returns></returns>
        Task<int> AddAsync<DTO>(DTO dto);
        Task<int> EditAsync(T obj);
        Task<int> DeleteAsync(Guid id);
        Task<int> EditAsync(T obj, params string[] fields);

        /// <summary>
        ///  标记删除
        /// </summary>
        Task<int> MarkDeleteAsync(Guid id);

        Task<bool> ExistsAsync(Expression<Func<T, bool>> expression);

        Task<T> GetEntityAsync(Expression<Func<T, bool>> expression);
        Task<T> GetEntityAsync(Guid id);

        IQueryable<T> GetList(Expression<Func<T, bool>> expression = null);

        IQueryable<T> GetList<TOrder>(Expression<Func<T, bool>> expression, int pageSize, int pageIndex, out int total, Expression<Func<T, TOrder>> order = null, bool IsAsc = true);
    }
}
